home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 2 / Atari Mega Archive CD - Volume 2.iso / minix / up1510b.tgz / up1510b / src / lib / posix / getlogin.c < prev    next >
C/C++ Source or Header  |  1990-07-23  |  453b  |  29 lines

  1. /*  getlogin(3)
  2.  *
  3.  *  Author: Terrence W. Holm          Aug. 1988
  4.  */
  5.  
  6. #include <lib.h>
  7. #include <pwd.h>
  8. #include <unistd.h>
  9. #include <string.h>
  10. #include <stdio.h>
  11.  
  12. #ifndef  L_cuserid
  13. #define  L_cuserid   9
  14. #endif
  15.  
  16. char *getlogin()
  17. {
  18.   PRIVATE char userid[L_cuserid];
  19.   struct passwd *pw_entry;
  20.  
  21.   pw_entry = getpwuid(getuid());
  22.  
  23.   if (pw_entry == (struct passwd *)NULL) return((char *)NULL);
  24.  
  25.   strcpy(userid, pw_entry->pw_name);
  26.  
  27.   return(userid);
  28. }
  29.